程序出错,无法解答``

来源:百度知道 编辑:UC知道 时间:2024/09/25 11:35:01
#include <iostream>
using namespace std;
int tip(int m);
int main()
{
cout <<"input a integer:"<<endl;
cin>>m;
if tip(m)
cout<< m <<" is a zhishu."<<endl;
else
cout<< m <<"is not a zhishu."<<endl;
return 0;
}
int tip(int m)
{
if(m%2==0)
if(m%3==0)
if(m%5==0)
if(m%7==0)
if(m%11==0)
cout <<m<<endl;
}
这个是我打的程序``
E:\shu ``\ex_1\main.cpp(7) : error C2065: 'm' : undeclared identifier
E:\shu ``\ex_1\main.cpp(8) : error C2061: syntax error : identifier 'tip'
E:\shu ``\ex_1\main.cpp(10) : error C2181: illegal else without matching if
E:\shu ``\ex_1\main.cpp(11) : error C2061: syntax error : identifier 'cout'
它有四个错误,
我实在不知道怎么觉得了``希望大家能帮帮我``

那么多的错误,居然说没有错,不知道你的错是个什么标准,固执不过计算机的,认错吧。

第一个错,你没有定义m,你应该在下面的语句:
int main()
{
之后添加下面一行:
int m;

第二个错,if语句的格式都不对,下面的语句:
if tip(m)
应该修改为:
if (tip(m))